index.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { useIsMFAEnabled } from 'common'
  2. import Link from 'next/link'
  3. import { Button } from 'ui'
  4. import { Admonition } from 'ui-patterns'
  5. import { ProjectList } from '@/components/interfaces/Home/ProjectList/ProjectList'
  6. import { HomePageActions } from '@/components/interfaces/HomePageActions'
  7. import DefaultLayout from '@/components/layouts/DefaultLayout'
  8. import OrganizationLayout from '@/components/layouts/OrganizationLayout'
  9. import { PageLayout } from '@/components/layouts/PageLayout/PageLayout'
  10. import { ScaffoldContainer, ScaffoldSection } from '@/components/layouts/Scaffold'
  11. import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
  12. import type { NextPageWithLayout } from '@/types'
  13. const ProjectsPage: NextPageWithLayout = () => {
  14. const isUserMFAEnabled = useIsMFAEnabled()
  15. const { data: org } = useSelectedOrganizationQuery()
  16. const disableAccessMfa = org?.organization_requires_mfa && !isUserMFAEnabled
  17. return (
  18. <ScaffoldContainer className="grow flex">
  19. <ScaffoldSection isFullWidth className="pb-0">
  20. {disableAccessMfa ? (
  21. <Admonition
  22. type="note"
  23. layout="horizontal"
  24. title={`${org?.name} requires MFA`}
  25. description={
  26. <>
  27. Set up multi-factor authentication (MFA) on your account to access this
  28. organization’s projects.
  29. </>
  30. }
  31. actions={
  32. <Button asChild type="default">
  33. <Link href="/account/security">Set up MFA</Link>
  34. </Button>
  35. }
  36. />
  37. ) : (
  38. <div className="flex flex-col gap-y-4">
  39. <HomePageActions />
  40. <ProjectList />
  41. </div>
  42. )}
  43. </ScaffoldSection>
  44. </ScaffoldContainer>
  45. )
  46. }
  47. ProjectsPage.getLayout = (page) => (
  48. <DefaultLayout>
  49. <OrganizationLayout title="Projects">
  50. <PageLayout title="Projects">{page}</PageLayout>
  51. </OrganizationLayout>
  52. </DefaultLayout>
  53. )
  54. export default ProjectsPage